define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'jskmsg/userwithdraw/index' + location.search,
                    add_url: 'jskmsg/userwithdraw/add',
                    edit_url: 'jskmsg/userwithdraw/edit',
                    del_url: 'jskmsg/userwithdraw/del',
                    multi_url: 'jskmsg/userwithdraw/multi',
                    import_url: 'jskmsg/userwithdraw/import',
                    table: 'user_withdraw',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), operate: false},
                        {field: 'type', title: __('Type'), searchList: {"balance":__('Type balance'),"redbag":__('Type redbag')}, formatter: Table.api.formatter.normal},
                        {field: 'user.nickname', title: __('User_nickname'),operate: 'LIKE'},
                        //{field: 'user.mobile', title: '手机号',operate: 'LIKE'},
                        //{field: 'bank', title: __('Bank'), operate: 'LIKE'},
                        {field: 'amount', title: __('Amount'), operate:false},//operate:'BETWEEN'
                        {field: 'fee', title: __('Fee'), operate:false},
                        {field: 'actual_amount', title: __('Actual_amount'), operate:false},
                        {field: 'real_name', title: '收款人', operate:'LIKE'},
                        {field: 'bank', title: '银行名称', operate:false},
                        {field: 'bank_card', title: '银行卡号', operate:false},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        {field: 'reason', title: __('Reason'), operate: false},
                        {field: 'createtime', title: __('Createtime'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
